package net.xdclass.manager.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import net.xdclass.manager.AccountManger;
import net.xdclass.mapper.AccountMapper;
import net.xdclass.model.AccountDO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 功能描述
 *
 * @author ASUS
 * @date 2024/07/02  17:32
 */
@Component
@Slf4j
public class AccountMangerImpl implements AccountManger {
    @Autowired
    private AccountMapper accountMapper;
    @Override
    public int insert(AccountDO accountDO) {
        return accountMapper.insert(accountDO);
    }

    @Override
    public List<AccountDO> findByPhone(String phone) {
        LambdaQueryWrapper<AccountDO> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(phone),AccountDO::getPhone,phone);
        List<AccountDO> accountDO = accountMapper.selectList(wrapper);
        return accountDO;
    }

    @Override
    public AccountDO detail(Long accountNo) {
        return accountMapper.selectOne(new QueryWrapper<AccountDO>().eq("account_no",
                accountNo));
    }
}
